package com.cinema.web;


import com.cinema.entity.Film;
import com.cinema.service.FilmService;
import com.cinema.util.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/film")
public class FilmController {

    @Autowired
    private FilmService filmService;
    @RequestMapping(value = "/queryfilmbyname",method = RequestMethod.GET)
    @ResponseBody
    //通过电影名查找电影信息
    private Map<String,Object> queryFilmByName(HttpServletRequest request) {

        Map<String, Object> modelMap = new HashMap<String, Object>();
        //通过电影名获取电影信息
        Film film1 = filmService.queryFilmByName("复仇者联盟4");
        Film film2 = filmService.queryFilmByName("怦然心动");
        Film film3 = filmService.queryFilmByName("这个杀手不太冷");
        if (film1 != null && film2 != null && film3 != null){
            modelMap.put("success",true);
            modelMap.put("film1",film1);
            modelMap.put("film2",film2);
            modelMap.put("film3",film3);
        }else {
            modelMap.put("success",false);
            modelMap.put("errMsg","没有电影信息");
        }
        return modelMap;
    }
}

